class Solution {
    //有效的数独
    public boolean isValidSudoku(char[][] board) {
        boolean[][] row = new boolean[9][10];
        boolean[][] col = new boolean[9][10];
        boolean[][][] grid = new boolean[3][3][10];
        for(int i = 0; i < 9; i++){
            for(int j = 0; j < 9; j++){
                if(board[i][j] != '.'){
                    int index = board[i][j] - '0';
                    //判断是否出现过
                    if(row[i][index] || col[j][index] || grid[i / 3][j / 3][index]){
                        return false;
                    }
                    row[i][index] = true;
                    col[j][index] = true;
                    grid[i / 3][j / 3][index] = true;
                }
            }
        }
        return true;
    }
}